package util;

import javax.servlet.ServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class StringUtil {
    /**
     * 判断字符串内容是否 空
     *
     * @param content
     * @return
     */
    public static boolean isEmpty(String content) {
        return content == null || content.length() == 0;
    }

    public static void setResponseContent(String encoding, ServletResponse response) {
        response.setCharacterEncoding(encoding);
        response.setContentType("text/html;charset=" + encoding);
    }

    public static void setResponseContent(ServletResponse response) {
        setResponseContent("utf-8", response);
    }
    public static PrintWriter getWriter(ServletResponse response) throws IOException {
        setResponseContent("utf-8", response);
        return response.getWriter();
    }
}
